<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        //定时器 反复循环
        var w =  setInterval("fn()",3000);
         function fn() {
         alert("789");
         }
        //循环一次
        /*var w = setTimeout("fn()",2000);
        function fn() {
            alert("789");
        }*/
        //清除重复定时器
        function fn1() {
            clearInterval(w)
        }
    </script>
</head>
<body>
<input type="button" value="点击清理定时器" onclick="fn1()">
</body>
</html>